package com.insurance.modules.claim.vo.convert;

import com.insurance.common.utils.AmountUtils;
import com.insurance.modules.claim.vo.response.CaseListExcelExport;
import com.insurance.modules.claim.vo.response.CaseListExportRsp;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @Author ws
 * @create 2022/10/21 17:29
 */
@Mapper(uses = {CustomConvert.class, AmountUtils.class})
public interface ClaimCaseExcelConvert {

    ClaimCaseExcelConvert INSTANCE = Mappers.getMapper(ClaimCaseExcelConvert.class);

    @Mapping(source = "corpName", target = "corpName")
    @Mappings({
        @Mapping(target = "insuranceStatus", expression = "java(CustomConvert.convertInsuranceStatus(vo.getInsuranceStatus()))"),
        @Mapping(target = "personnelSort", expression = "java(CustomConvert.convertPersonnelSort(vo.getPersonnelSort()))"),
        @Mapping(target = "outsourcingFlag", expression = "java(CustomConvert.convertOutsourcingFlag(vo.getOutsourcingFlag()))"),
        @Mapping(target = "accidentType", expression = "java(CustomConvert.convertAccidentType(vo.getAccidentType()))"),
        @Mapping(target = "accidentNature", expression = "java(CustomConvert.convertAccidentNature(vo.getAccidentNature()))"),
        @Mapping(target = "caseStatus", expression = "java(CustomConvert.convertCaseStatus(vo.getCaseStatus()))"),
        @Mapping(target = "disabilityAppraisalLevel", expression = "java(CustomConvert.convertDisabilityAppraisalLevel(vo.getDisabilityAppraisalLevel()))"),
        @Mapping(target = "accidentLiability", expression = "java(CustomConvert.convertAccidentLiability(vo.getAccidentLiability()))"),
        @Mapping(target = "treatmentType", expression = "java(CustomConvert.convertTreatmentType(vo.getTreatmentType()))"),
        @Mapping(target = "reportTime", dateFormat = "yyyy-MM-dd HH:mm:ss"),
        @Mapping(target = "accidentTime", dateFormat = "yyyy-MM-dd HH:mm:ss"),
        @Mapping(target = "sendTime", dateFormat = "yyyy-MM-dd HH:mm:ss"),
        @Mapping(target = "closeTime", dateFormat = "yyyy-MM-dd HH:mm:ss"),
        @Mapping(target = "applyAmount", expression = "java(AmountUtils.fenToYuanBigDecimal(vo.getApplyAmount()))"),
        @Mapping(target = "totalAmount", expression = "java(AmountUtils.fenToYuanBigDecimal(vo.getTotalAmount()))"),
        @Mapping(target = "selfAmount", expression = "java(AmountUtils.fenToYuanBigDecimal(vo.getSelfAmount()))"),
        @Mapping(target = "insuredAmount", expression = "java(AmountUtils.fenToYuanBigDecimal(vo.getInsuredAmount()))"),
        @Mapping(target = "startTime", expression = "java(CustomConvert.joinTime(vo.getStartTime(), vo.getEndTime()))"),
        @Mapping(target = "treatAgainFlag", expression = "java(CustomConvert.convertTreatAgainFlag(vo.getTreatAgainFlag()))"),
        @Mapping(target = "familyWantAmount", expression = "java(AmountUtils.fenToYuanBigDecimal(vo.getFamilyWantAmount()))"),
        @Mapping(target = "treatmentAmount", expression = "java(AmountUtils.fenToYuanBigDecimal(vo.getTreatmentAmount()))"),
        @Mapping(target = "delayWorkAmount", expression = "java(AmountUtils.fenToYuanBigDecimal(vo.getDelayWorkAmount()))"),
        @Mapping(target = "deathAmount", expression = "java(AmountUtils.fenToYuanBigDecimal(vo.getDeathAmount()))"),
        @Mapping(target = "disabilityAmount", expression = "java(AmountUtils.fenToYuanBigDecimal(vo.getDisabilityAmount()))"),
        @Mapping(target = "disabilityAppraisalAmount", expression = "java(AmountUtils.fenToYuanBigDecimal(vo.getDisabilityAppraisalAmount()))"),
        @Mapping(target = "publicAmount", expression = "java(AmountUtils.fenToYuanBigDecimal(vo.getPublicAmount()))"),
        @Mapping(target = "employerAmount", expression = "java(AmountUtils.fenToYuanBigDecimal(vo.getEmployerAmount()))"),
        @Mapping(target = "invoiceAmount", expression = "java(AmountUtils.fenToYuanBigDecimal(vo.getInvoiceAmount()))"),
    })
    CaseListExcelExport convert(CaseListExportRsp vo);

    List<CaseListExcelExport> convert(List<CaseListExportRsp> vo);
}
